﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using blackhouse.WebNemo.Business;
using blackhouse.WebNemo.Data;
using blackhouse.WebNemo.Cms.Data;
using blackhouse.WebNemo.Data.Cache;

namespace blackhouse.WebNemo.Cms {
    public class CmsFactory : SqlFactory {

        public override IDataAccess GetDataAccess() {
            IDataAccess cmsData = null;
            ISupportSystemNames ssn = null;
            if (new SqlFactory().GetUsingVersion() == "Stronger") {
                cmsData = new CmsDataAccessStronger(GetConnectionString());
            }
            else
                cmsData = new CmsDataAccess(GetConnectionString());
            ssn = cmsData as ISupportSystemNames;
            if (ssn != null)
                ssn.Names = new SystemNames(cmsData);

            return new CacheDataAccess(cmsData, TimeSpan.FromMinutes(20), GetConnectionString());
        }

        protected override Business.Users.INemoUser CreateUser() {
            return new CmsNemoUser(base.CreateUser());
        }

    }
}